<?php
class NewMailVo extends SzAbstractMySqlVo
{

    private $userId;
    private $mailId;
    private $type;
    private $title1;
    private $title2;
    private $title3;
    private $reward;
    private $status;
    private $createTime;

    /**
     * Initialize NewMailVo.
     *
     * @param $userId
     * @param $mailId
     * @param $type
     * @param $title1
     * @param $title2
     * @param $title3
     * @param $reward
     * @param $status
     * @param $createTime
     * @param boolean $isInsert default false, means for now this vo is initialized not for insert process
     * @return NewMailVo
     */
    public function __construct($userId, $mailId, $type, $title1, $title2, $title3, $reward, $status, $createTime, $isInsert = false) {
        $this->userId = $userId;
        $this->mailId = $mailId;
        $this->type = $type;
        $this->title1 = $title1;
        $this->title2 = $title2;
        $this->title3 = $title3;
        $this->reward = json_decode($reward, true);
        $this->status = $status;
        $this->createTime = $createTime;

        $this->isInsert = $isInsert;
        $this->voClassName = 'NewMailVo';
        $this->ormName = 'NewMail';
    }

    /**
     * @see SzAbstractVo::toArray
     */
    public function toArray($needEncode = false)
    {
        return array(
            'userId' => $this->getUserId(),
            'mailId' => $this->getMailId(),
            'type' => $this->getType(),
            'title1' => $this->getTitle1(),
            'title2' => $this->getTitle2(),
            'title3' => $this->getTitle3(),
            'reward' => ($needEncode) ? $this->getReward() : $this->getRawReward(),
            'status' => $this->getStatus(),
            'createTime' => $this->getCreateTime(),
        );
    }

    /**
     * @see SzAbstractVo::toEntireArray
     */
    public function toEntireArray($needEncode = false)
    {
        return array(
            'userId' => $this->getUserId(),
            'mailId' => $this->getMailId(),
            'type' => $this->getType(),
            'title1' => $this->getTitle1(),
            'title2' => $this->getTitle2(),
            'title3' => $this->getTitle3(),
            'reward' => ($needEncode) ? $this->getReward() : $this->getRawReward(),
            'status' => $this->getStatus(),
            'createTime' => $this->getCreateTime(),
        );
    }

    /**
     * @see SzAbstractVo::toPureArray
     */
    public function toPureArray()
    {
        return array(
            $this->getUserId(),
            $this->getMailId(),
            $this->getType(),
            $this->getTitle1(),
            $this->getTitle2(),
            $this->getTitle3(),
            $this->getReward(),
            $this->getStatus(),
            $this->getCreateTime(),
        );
    }

    public function getUserId()
    {
        return $this->userId;
    }

    public function setUserId($val)
    {
        $this->saveColumnStatus(0, $this->userId);
        $this->userId = $val;
    }

    public function getMailId()
    {
        return $this->mailId;
    }

    public function setMailId($val)
    {
        $this->saveColumnStatus(1, $this->mailId);
        $this->mailId = $val;
    }

    public function getType()
    {
        return $this->type;
    }

    public function setType($val)
    {
        $this->saveColumnStatus(2, $this->type);
        $this->type = $val;
    }

    public function getTitle1()
    {
        return $this->title1;
    }

    public function setTitle1($val)
    {
        $this->saveColumnStatus(3, $this->title1);
        $this->title1 = $val;
    }

    public function getTitle2()
    {
        return $this->title2;
    }

    public function setTitle2($val)
    {
        $this->saveColumnStatus(4, $this->title2);
        $this->title2 = $val;
    }

    public function getTitle3()
    {
        return $this->title3;
    }

    public function setTitle3($val)
    {
        $this->saveColumnStatus(5, $this->title3);
        $this->title3 = $val;
    }

    public function getReward()
    {
        return json_encode($this->reward);
    }

    public function getRawReward()
    {
        return $this->reward;
    }

    public function setReward($val)
    {
        $encodedLength = SzUtility::strLen(json_encode($val));
        if ($encodedLength > 218400) {
            SzLogger::get()->error('[NewMailVo] The length of column reward exceed the limit, length / limit: ' . $encodedLength . ' / 218400');
            throw new SzException(10522, array('NewMailVo', '218400', $encodedLength));
        } else if ($encodedLength > 196560) {
            SzLogger::get()->warn('[NewMailVo] The length of column reward exceed the warning level, length / limit: ' . $encodedLength . ' / 218400');
        }
        $this->saveColumnStatus(6, $this->reward);
        $this->reward = $val;
    }

    public function getStatus()
    {
        return $this->status;
    }

    public function setStatus($val)
    {
        $this->saveColumnStatus(7, $this->status);
        $this->status = $val;
    }

    public function getCreateTime()
    {
        return $this->createTime;
    }

    public function setCreateTime($val)
    {
        $this->saveColumnStatus(8, $this->createTime);
        $this->createTime = $val;
    }

}